
clear all

*log using "R:\WSV2\TBu_BMa\Subsidies Project\Results\AT_Programs_Estimates_2023.smcl", replace


use "Estimation Sample.dta" 

preserve

********************************************************************************************************************************************************************************************************************
*************************************************AUSTRIA************************************************************************************************************************************************************
*************************************************Refrigerator-Freezer Program**2009*********************************************************************************************************************************
*************************************************Effects on Unit Sales and Prices of Subsidized and Non-subsidized**************************************************************************************************
********************************************************************************************************************************************************************************************************************

drop if category=="washing machine"

set more off

gen tall=0
replace tall=1 if (main_type!="1 DOOR 81 - 90 CM" & main_type!="1 DOOR UP TO 80 CM")

egen cmt=group(country month treataf)
egen cy=group(country year)
encode country, gen(c)
 
xtset id2

egen median=median(price) if year==2009 & treataf==1 & month==7
gen mprice=1 if price>median & treataf==1 & year==2009 & month==7 & price!=.
replace mprice=0 if price<=median & treataf==1 & year==2009 & month==7 & price!=.
by id, sort: egen summp=sum(mprice)
by id, sort: gen medprice=1 if summp>0
replace medprice=0 if summp==0


*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***UNIT SALES, SUBSIDIZED (3-MONTH WINDOW)

reghdfe dlogunits i.presub3af9##ib1.treataf i.presub2af9##ib1.treataf i.presub1af9##ib1.treataf i.sub1af9##ib1.treataf i.sub2af9##ib1.treataf i.sub3af9##ib1.treataf i.sub4af9##ib1.treataf i.postsub1af9##ib1.treataf i.postsub2af9##ib1.treataf i.postsub3af9##ib1.treataf  mage mage2 , absorb(id2 cmt) cluster(id) 
est store subu
		generate samples = e(sample)
		codebook id if samples
		codebook id if samples & treataf==1
				
				
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)) 
					(preshift: 	1/2*(exp(_b[1.presub1af9])*(1+exp(_b[1.presub2af9]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9])*exp(_b[1.postsub1af9])*(1+exp(_b[1.postsub2af9]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift]
		
		***Program cost
		nlcom 		1000*2700613/((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*63.16), level(90)
		
		***Program cost (25th percentile)
		nlcom 		1000*2700613/((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*95.99), level(90)
		
		***Program cost (10th percentile)
		nlcom 		1000*2700613/((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*137.99), level(90)

		***Energy savings in MWh
		nlcom           ((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*63.16)/1000, level(90)


*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***UNIT SALES, SUBSIDIZED (CY-fixed effects)

reghdfe dlogunits i.presub3af9##ib1.treataf i.presub2af9##ib1.treataf i.presub1af9##ib1.treataf i.sub1af9##ib1.treataf i.sub2af9##ib1.treataf i.sub3af9##ib1.treataf i.sub4af9##ib1.treataf i.postsub1af9##ib1.treataf i.postsub2af9##ib1.treataf i.postsub3af9##ib1.treataf  mage mage2 , absorb(id2 cmt cy) cluster(id) 
			
est store subu_cy				
***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)) 
					(preshift: 	1/2*(exp(_b[1.presub1af9])*(1+exp(_b[1.presub2af9]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9])*exp(_b[1.postsub1af9])*(1+exp(_b[1.postsub2af9]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift]
		
		***Program cost
		nlcom 		1000*2700613/((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*63.16), level(90)

		***Energy savings in MWh
		nlcom           ((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*63.16)/1000, level(90)
		
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***UNIT SALES, SUBSIDIZED (country-specific linear date trends)

reghdfe dlogunits i.presub3af9##ib1.treataf i.presub2af9##ib1.treataf i.presub1af9##ib1.treataf i.sub1af9##ib1.treataf i.sub2af9##ib1.treataf i.sub3af9##ib1.treataf i.sub4af9##ib1.treataf i.postsub1af9##ib1.treataf i.postsub2af9##ib1.treataf i.postsub3af9##ib1.treataf  mage mage2 , absorb(id2 cmt i.c#c.date) cluster(id) 
			
est store subu_trends				
***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)) 
					(preshift: 	1/2*(exp(_b[1.presub1af9])*(1+exp(_b[1.presub2af9]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9])*exp(_b[1.postsub1af9])*(1+exp(_b[1.postsub2af9]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift]
		
		***Program cost
		nlcom 		1000*2700613/((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*63.16), level(90)

		***Energy savings in MWh
		nlcom           ((_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift])*15704.87*18*63.16)/1000, level(90)		
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	
***UNIT SALES, SUBSIDIZED (response above and below price median)
reghdfe dlogunits i.presub3af9##ib1.treataf##ib1.medprice i.presub2af9##ib1.treataf##ib1.medprice i.presub1af9##ib1.treataf##ib1.medprice i.sub1af9##ib1.treataf##ib1.medprice i.sub2af9##ib1.treataf##ib1.medprice i.sub3af9##ib1.treataf##ib1.medprice i.sub4af9##ib1.treataf##ib1.medprice i.postsub1af9##ib1.treataf##ib1.medprice i.postsub2af9##ib1.treataf##ib1.medprice i.postsub3af9##ib1.treataf##ib1.medprice  mage mage2 , absorb(id2 cmt) cluster(id)

est store subu_above


reghdfe dlogunits i.presub3af9##ib1.treataf##ib0.medprice i.presub2af9##ib1.treataf##ib0.medprice i.presub1af9##ib1.treataf##ib0.medprice i.sub1af9##ib1.treataf##ib0.medprice i.sub2af9##ib1.treataf##ib0.medprice i.sub3af9##ib1.treataf##ib0.medprice i.sub4af9##ib1.treataf##ib0.medprice i.postsub1af9##ib1.treataf##ib0.medprice i.postsub2af9##ib1.treataf##ib0.medprice i.postsub3af9##ib1.treataf##ib0.medprice  mage mage2 , absorb(id2 cmt) cluster(id)

est store subu_below


esttab   subu subu_above subu_below , se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 

esttab   subu subu_above subu_below  using "AT_09_medianprice.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
***UNIT SALES, NON-SUBSIDIZED

reghdfe dlogunits i.presub3af9##i.treataf i.presub2af9##i.treataf i.presub1af9##i.treataf i.sub1af9##i.treataf i.sub2af9##i.treataf i.sub3af9##i.treataf i.sub4af9##i.treataf i.postsub1af9##i.treataf i.postsub2af9##i.treataf i.postsub3af9##i.treataf  mage mage2 , absorb(id2 cmt) cluster(id)
est store nonsubu
    	
		
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)) 
					(preshift: 	1/2*(exp(_b[1.presub1af9])*(1+exp(_b[1.presub2af9]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9])*exp(_b[1.postsub1af9])*(1+exp(_b[1.postsub2af9]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift]

		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
***PRICES, SUBSIDIZED

reghdfe dlogprice i.presub3af9##ib1.treataf i.presub2af9##ib1.treataf i.presub1af9##ib1.treataf i.sub1af9##ib1.treataf i.sub2af9##ib1.treataf i.sub3af9##ib1.treataf i.sub4af9##ib1.treataf i.postsub1af9##ib1.treataf i.postsub2af9##ib1.treataf i.postsub3af9##ib1.treataf  mage mage2 if samples , absorb(id2 cmt) cluster(id)
est store subp
		
		nlcom 	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)
		
		
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***PRICES, NON-SUBSIDIZED

reghdfe dlogprice i.presub3af9##i.treataf i.presub2af9##i.treataf i.presub1af9##i.treataf i.sub1af9##i.treataf i.sub2af9##i.treataf i.sub3af9##i.treataf i.sub4af9##i.treataf i.postsub1af9##i.treataf i.postsub2af9##i.treataf i.postsub3af9##i.treataf  mage mage2 if samples , absorb(id2 cmt) cluster(id)
est store nonsubp	

		nlcom 	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)

			
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***RESPONSE BY HEIGHT OF REFRIGERATORS/FREEZERS

egen cmth=group(country month treataf tall)

***ABOVE 90 CM, UNITS
reghdfe dlogunits i.presub3af9##ib1.treataf##ib1.tall i.presub2af9##ib1.treataf##ib1.tall i.presub1af9##ib1.treataf##ib1.tall i.sub1af9##ib1.treataf##ib1.tall i.sub2af9##ib1.treataf##ib1.tall i.sub3af9##ib1.treataf##ib1.tall i.sub4af9##ib1.treataf##ib1.tall i.postsub1af9##ib1.treataf##ib1.tall i.postsub2af9##ib1.treataf##ib1.tall i.postsub3af9##ib1.treataf##ib1.tall  mage mage2 , absorb(id2 cmth) cluster(id)
est store subtallu

		gen samplet=e(sample)
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)) 
					(preshift: 	1/2*(exp(_b[1.presub1af9])*(1+exp(_b[1.presub2af9]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9])*exp(_b[1.postsub1af9])*(1+exp(_b[1.postsub2af9]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift]
	

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***SMALLER OR EQUAL 90CM, UNITS

reghdfe dlogunits i.presub3af9##ib1.treataf##i.tall i.presub2af9##ib1.treataf##i.tall i.presub1af9##ib1.treataf##i.tall i.sub1af9##ib1.treataf##i.tall i.sub2af9##ib1.treataf##i.tall i.sub3af9##ib1.treataf##i.tall i.sub4af9##ib1.treataf##i.tall i.postsub1af9##ib1.treataf##i.tall i.postsub2af9##ib1.treataf##i.tall i.postsub3af9##ib1.treataf##i.tall  mage mage2 , absorb(id2 cmth) cluster(id)
est store subshortu

		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/4*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*(1+exp(_b[1.sub2af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])+exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9]))-4)) 
					(preshift: 	1/2*(exp(_b[1.presub1af9])*(1+exp(_b[1.presub2af9]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af9])*exp(_b[1.presub1af9])*exp(_b[1.sub1af9])*exp(_b[1.sub2af9])*exp(_b[1.sub3af9])*exp(_b[1.sub4af9])*exp(_b[1.postsub1af9])*(1+exp(_b[1.postsub2af9]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/4)*_b[preshift]+ (2/4)*_b[postshift]

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***ABOVE 90 CM, PRICES

reghdfe dlogprice i.presub3af9##ib1.treataf##ib1.tall i.presub2af9##ib1.treataf##ib1.tall i.presub1af9##ib1.treataf##ib1.tall i.sub1af9##ib1.treataf##ib1.tall i.sub2af9##ib1.treataf##ib1.tall i.sub3af9##ib1.treataf##ib1.tall i.sub4af9##ib1.treataf##ib1.tall i.postsub1af9##ib1.treataf##ib1.tall i.postsub2af9##ib1.treataf##ib1.tall i.postsub3af9##ib1.treataf##ib1.tall  mage mage2  if samplet , absorb(id2 cmth) cluster(id)
		est store subtallp
	
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***SMALLER OR EQUAL 90CM, PRICES

reghdfe dlogprice i.presub3af9##ib1.treataf##i.tall i.presub2af9##ib1.treataf##i.tall i.presub1af9##ib1.treataf##i.tall i.sub1af9##ib1.treataf##i.tall i.sub2af9##ib1.treataf##i.tall i.sub3af9##ib1.treataf##i.tall i.sub4af9##ib1.treataf##i.tall i.postsub1af9##ib1.treataf##i.tall i.postsub2af9##ib1.treataf##i.tall i.postsub3af9##ib1.treataf##i.tall  mage mage2  if samplet  , absorb(id2 cmth) cluster(id)
		est store subshortp


		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

***TABLES
**UNITS AND PRICES
esttab   subu nonsubu subp nonsubp , se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 

esttab   subu nonsubu subp nonsubp using "AT_09.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9 ) 

esttab   subu_cy subu_trends,  se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9)

esttab   subu_cy subu_trends using "AT_09_cy.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 

**UNITS AND PRICES BY HEIGHT
esttab  subtallu subshortu  subtallp subshortp , se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9 ) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 

esttab   subtallu subshortu  subtallp subshortp  using "AT_09_tall.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9 ) keep(1.presub3af9 1.presub2af9 1.presub1af9 1.sub1af9 1.sub2af9 1.sub3af9 1.sub4af9 1.postsub1af9 1.postsub2af9 1.postsub3af9) 		
		
	
restore

preserve	

********************************************************************************************************************************************************************************************************************
*************************************************AUSTRIA************************************************************************************************************************************************************
*************************************************Refrigerator-Freezer Program**2010*********************************************************************************************************************************
*************************************************Effects on Unit Sales and Prices of Subsidized and Non-subsidized**************************************************************************************************
********************************************************************************************************************************************************************************************************************

set more off

gen tall=0
replace tall=1 if (main_type!="1 DOOR 81 - 90 CM" & main_type!="1 DOOR UP TO 80 CM")

egen cmt=group(country month treataf)
egen cy =group(country year)
encode country, gen(c)

xtset id2

drop if category=="washing machine"
egen median=median(price) if year==2010 & treataf==1 & month==7
gen mprice=1 if price>median & treataf==1 & year==2010 & month==7 & price!=.
replace mprice=0 if price<=median & treataf==1 & year==2010 & month==7 & price!=.
by id, sort: egen summp=sum(mprice)
by id, sort: gen medprice=1 if summp>0
replace medprice=0 if summp==0
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***UNIT SALES, SUBSIDIZED (3-MONTH WINDOW)

reghdfe dlogunits i.presub3af10##ib1.treataf i.presub2af10##ib1.treataf i.presub1af10##ib1.treataf i.sub1af10##ib1.treataf i.sub2af10##ib1.treataf i.sub3af10##ib1.treataf i.postsub1af10##ib1.treataf i.postsub2af10##ib1.treataf i.postsub3af10##ib1.treataf  mage mage2 , absorb(id2 cmt) cluster(id)
est store subu
generate samples = e(sample)
codebook id if samples
codebook id if samples & treataf==1
		
		
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)) 
					(preshift: 	1/2*(exp(_b[1.presub1af10])*(1+exp(_b[1.presub2af10]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*exp(_b[1.sub2af10])*exp(_b[1.sub3af10])*exp(_b[1.postsub1af10])*(1+exp(_b[1.postsub2af10]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift]
		
		***Program cost
		nlcom 		1000*1641366/((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)
		
		***Program cost (25th percentile)
		nlcom 		1000*1641366/((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*93)
		
		***Program cost (10th percentile)
		nlcom 		1000*1641366/((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*132.84)
		
		***Energy savings
		nlcom 		((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)/1000, level (90)

		
		***Energy savings in MWh
		nlcom           ((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)/1000, level(90)
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***UNIT SALES, SUBSIDIZED (CY-fixed effects)

reghdfe dlogunits i.presub3af10##ib1.treataf i.presub2af10##ib1.treataf i.presub1af10##ib1.treataf i.sub1af10##ib1.treataf i.sub2af10##ib1.treataf i.sub3af10##ib1.treataf i.postsub1af10##ib1.treataf i.postsub2af10##ib1.treataf i.postsub3af10##ib1.treataf  mage mage2 , absorb(id2 cmt cy) cluster(id)
est store subu_cy
		
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)) 
					(preshift: 	1/2*(exp(_b[1.presub1af10])*(1+exp(_b[1.presub2af10]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*exp(_b[1.sub2af10])*exp(_b[1.sub3af10])*exp(_b[1.postsub1af10])*(1+exp(_b[1.postsub2af10]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift]
		
		***Program cost
		nlcom 		1000*1641366/((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)
		***Energy savings
		nlcom 		((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)/1000, level (90)

		
		***Energy savings in MWh
		nlcom           ((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)/1000, level(90)
	
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***UNIT SALES, SUBSIDIZED (country-specific linear time trends)

reghdfe dlogunits i.presub3af10##ib1.treataf i.presub2af10##ib1.treataf i.presub1af10##ib1.treataf i.sub1af10##ib1.treataf i.sub2af10##ib1.treataf i.sub3af10##ib1.treataf i.postsub1af10##ib1.treataf i.postsub2af10##ib1.treataf i.postsub3af10##ib1.treataf  mage mage2 , absorb(id2 cmt i.c#c.date) cluster(id)
est store subu_trends
		
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)) 
					(preshift: 	1/2*(exp(_b[1.presub1af10])*(1+exp(_b[1.presub2af10]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*exp(_b[1.sub2af10])*exp(_b[1.sub3af10])*exp(_b[1.postsub1af10])*(1+exp(_b[1.postsub2af10]))-2)), post;			
		#delimit cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift]
		
		***Program cost
		nlcom 		1000*1641366/((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)
		***Energy savings
		nlcom 		((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)/1000, level (90)

		
		***Energy savings in MWh
		nlcom           ((_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift])*13696.96*18*53.87)/1000, level(90)
			
			
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***UNIT SALES, SUBSIDIZED (above -below median price)			

reghdfe dlogunits i.presub3af10##ib1.treataf##ib1.medprice i.presub2af10##ib1.treataf##ib1.medprice i.presub1af10##ib1.treataf##ib1.medprice i.sub1af10##ib1.treataf##ib1.medprice i.sub2af10##ib1.treataf##ib1.medprice i.sub3af10##ib1.treataf##ib1.medprice i.postsub1af10##ib1.treataf##ib1.medprice i.postsub2af10##ib1.treataf##ib1.medprice i.postsub3af10##ib1.treataf##ib1.medprice  mage mage2 , absorb(id2 cmt) cluster(id)
est store subu_above

reghdfe dlogunits i.presub3af10##ib1.treataf##ib0.medprice i.presub2af10##ib1.treataf##ib0.medprice i.presub1af10##ib1.treataf##ib0.medprice i.sub1af10##ib1.treataf##ib0.medprice i.sub2af10##ib1.treataf##ib0.medprice i.sub3af10##ib1.treataf##ib0.medprice i.postsub1af10##ib1.treataf##ib0.medprice i.postsub2af10##ib1.treataf##ib0.medprice i.postsub3af10##ib1.treataf##ib0.medprice  mage mage2 , absorb(id2 cmt) cluster(id)
est store subu_below

esttab   subu subu_above subu_below, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) 		

esttab   subu subu_above subu_below  using "AT_10_ff_medianprice.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) 
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
***UNIT SALES, NON-SUBSIDIZED

reghdfe dlogunits i.presub3af10##i.treataf i.presub2af10##i.treataf i.presub1af10##i.treataf i.sub1af10##i.treataf i.sub2af10##i.treataf i.sub3af10##i.treataf i.postsub1af10##i.treataf i.postsub2af10##i.treataf i.postsub3af10##i.treataf  mage mage2 , absorb(id2 cmt) cluster(id)
est store nonsubu
     	
		***Program, preshift and postshift effects
		#delimit;
		nlcom 		(program:  	1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)) 
					(preshift: 	1/2*(exp(_b[1.presub1af10])*(1+exp(_b[1.presub2af10]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*exp(_b[1.sub2af10])*exp(_b[1.sub3af10])*exp(_b[1.postsub1af10])*(1+exp(_b[1.postsub2af10]))-2)), post;			
		#delimit cr
					
		***Net program effect
		nlcom 		_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift]
 		
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***PRICES, SUBSIDIZED

reghdfe dlogprice i.presub3af10##ib1.treataf i.presub2af10##ib1.treataf i.presub1af10##ib1.treataf i.sub1af10##ib1.treataf i.sub2af10##ib1.treataf i.sub3af10##ib1.treataf i.postsub1af10##ib1.treataf i.postsub2af10##ib1.treataf i.postsub3af10##ib1.treataf  mage mage2 if samples, absorb(id2 cmt) cluster(id)
est store subp

		nlcom 1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)

		
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
***PRICES, NON-SUBSIDIZED	
	
reghdfe dlogprice i.presub3af10##i.treataf i.presub2af10##i.treataf i.presub1af10##i.treataf i.sub1af10##i.treataf i.sub2af10##i.treataf i.sub3af10##i.treataf i.postsub1af10##i.treataf i.postsub2af10##i.treataf i.postsub3af10##i.treataf  mage mage2 if samples, absorb(id2 cmt) cluster(id)
est store nonsubp

		nlcom 1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)



*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***RESPONSE BY HEIGHT OF REFRIGERATORS/FREEZERS

egen cmth=group(country month treataf tall)

***ABOVE 90 CM, UNITS
reghdfe dlogunits i.presub3af10##ib1.treataf##ib1.tall i.presub2af10##ib1.treataf##ib1.tall i.presub1af10##ib1.treataf##ib1.tall i.sub1af10##ib1.treataf##ib1.tall i.sub2af10##ib1.treataf##ib1.tall i.sub3af10##ib1.treataf##ib1.tall i.postsub1af10##ib1.treataf##ib1.tall i.postsub2af10##ib1.treataf##ib1.tall i.postsub3af10##ib1.treataf##ib1.tall  mage mage2 , absorb(id2 cmth) cluster(id)
est store subtallu
gen samplet=e(sample)
		
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)) 
					(preshift: 	1/2*(exp(_b[1.presub1af10])*(1+exp(_b[1.presub2af10]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*exp(_b[1.sub2af10])*exp(_b[1.sub3af10])*exp(_b[1.postsub1af10])*(1+exp(_b[1.postsub2af10]))-2)), post;			
		#delimit cr
					
		***Net program effect (switching)
		nlcom 		_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift]
		
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***SMALLER OR EQUAL 90CM, UNITS

reghdfe dlogunits i.presub3af10##ib1.treataf##i.tall i.presub2af10##ib1.treataf##i.tall i.presub1af10##ib1.treataf##i.tall i.sub1af10##ib1.treataf##i.tall i.sub2af10##ib1.treataf##i.tall i.sub3af10##ib1.treataf##i.tall i.postsub1af10##ib1.treataf##i.tall i.postsub2af10##ib1.treataf##i.tall i.postsub3af10##ib1.treataf##i.tall  mage mage2 , absorb(id2 cmth) cluster(id)
est store subshortu
		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/3*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*(1+exp(_b[1.sub2af10])+exp(_b[1.sub2af10])*exp(_b[1.sub3af10]))-3)) 
					(preshift: 	1/2*(exp(_b[1.presub1af10])*(1+exp(_b[1.presub2af10]))-2))
					(postshift:	1/2*(exp(_b[1.presub2af10])*exp(_b[1.presub1af10])*exp(_b[1.sub1af10])*exp(_b[1.sub2af10])*exp(_b[1.sub3af10])*exp(_b[1.postsub1af10])*(1+exp(_b[1.postsub2af10]))-2)), post;			
		#delimit cr
					
		***Net program effect (switching)
		nlcom 		_b[program] + (2/3)*_b[preshift]+ (2/3)*_b[postshift]
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***ABOVE 90 CM, PRICES

reghdfe dlogprice i.presub3af10##ib1.treataf##ib1.tall i.presub2af10##ib1.treataf##ib1.tall i.presub1af10##ib1.treataf##ib1.tall i.sub1af10##ib1.treataf##ib1.tall i.sub2af10##ib1.treataf##ib1.tall i.sub3af10##ib1.treataf##ib1.tall i.postsub1af10##ib1.treataf##ib1.tall i.postsub2af10##ib1.treataf##ib1.tall i.postsub3af10##ib1.treataf##ib1.tall  mage mage2 if samplet , absorb(id2 cmth) cluster(id)
est store subtallp

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***SMALLER OR EQUAL 90CM, PRICES

reghdfe dlogprice i.presub3af10##ib1.treataf##i.tall i.presub2af10##ib1.treataf##i.tall i.presub1af10##ib1.treataf##i.tall i.sub1af10##ib1.treataf##i.tall i.sub2af10##ib1.treataf##i.tall i.sub3af10##ib1.treataf##i.tall i.postsub1af10##ib1.treataf##i.tall i.postsub2af10##ib1.treataf##i.tall i.postsub3af10##ib1.treataf##i.tall  mage mage2 if samplet  , absorb(id2 cmth) cluster(id)
est store subshortp
				


*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***TABLES

**UNITS AND PRICES
esttab   subu nonsubu  subp nonsubp, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10 ) 

esttab   subu nonsubu  subp nonsubp  using "AT_10_ff.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) 

esttab   subu_cy subu_trends,  se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) 

esttab   subu_cy subu_trends  using "AT_10_ff_cy.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) 

****UNITS AND PRICES BY HEIGHT
esttab   subtallu subshortu  subtallp subshortp, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f) scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10 ) 

esttab   subtallu subshortu  subtallp subshortp using "AT_10_ff_tall.tex", replace  se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) keep(1.presub3af10 1.presub2af10 1.presub1af10 1.sub1af10 1.sub2af10 1.sub3af10 1.postsub1af10 1.postsub2af10 1.postsub3af10) 

restore

preserve

********************************************************************************************************************************************************************************************************************
*************************************************AUSTRIA************************************************************************************************************************************************************
*************************************************Washing Machine Program**2010**************************************************************************************************************************************
*************************************************Effects on Unit Sales and Prices of Subsidized and Non-subsidized**************************************************************************************************
********************************************************************************************************************************************************************************************************************	

egen cmt=group(country month treata)
egen cy= group(country year)

 encode country, gen(c)
 xtset id2
 
 keep if category=="washing machine"
 
egen median=median(price) if year==2010 & treata==1 & month==2
gen mprice=1 if price>median & treata==1 & year==2010 & month==2 & price!=.
replace mprice=0 if price<=median & treata==1 & year==2010 & month==2 & price!=.
by id, sort: egen summp=sum(mprice)
by id, sort: gen medprice=1 if summp>0
replace medprice=0 if summp==0
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
***UNIT SALES, SUBSIDIZED (3-MONTH WINDOW)

reghdfe dlogunits i.presub3a##ib1.treata i.presub2a##ib1.treata i.presub1a##ib1.treata i.sub1a##ib1.treata i.sub2a##ib1.treata i.postsub1a##ib1.treata i.postsub2a##ib1.treata i.postsub3a##ib1.treata  mage mage2 , absorb(id2 cmt) cluster(id) 
est store subu
generate samples = e(sample)
codebook id if samples
codebook id if samples & treata==1
		
     	
		 ***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*(1+exp(_b[1.sub2a]))-2)) 
					(preshift: 	1/2*(exp(_b[1.presub1a])*(1+exp(_b[1.presub2a]))-2))
					(postshift:	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*exp(_b[1.sub2a])*exp(_b[1.postsub1a])*(1+exp(_b[1.postsub2a]))-2)), post;			
		#delimit    cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift]
		
		***Program cost
		nlcom 		1000*931986/((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*69.41), level(90)
		
		***Program cost (25th percentile)
		nlcom 		1000*931986/((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*75.68), level(90)
		
		***Program cost (10th percentile)
		nlcom 		1000*931986/((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*91.68), level(90)
		
		***Energy savings
		nlcom 		((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*69.41)/1000, level(90)
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
***UNIT SALES, SUBSIDIZED (cy)

reghdfe dlogunits i.presub3a##ib1.treata i.presub2a##ib1.treata i.presub1a##ib1.treata i.sub1a##ib1.treata i.sub2a##ib1.treata i.postsub1a##ib1.treata i.postsub2a##ib1.treata i.postsub3a##ib1.treata  mage mage2 , absorb(id2 cmt cy) cluster(id) 
est store subu_cy

***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*(1+exp(_b[1.sub2a]))-2)) 
					(preshift: 	1/2*(exp(_b[1.presub1a])*(1+exp(_b[1.presub2a]))-2))
					(postshift:	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*exp(_b[1.sub2a])*exp(_b[1.postsub1a])*(1+exp(_b[1.postsub2a]))-2)), post;			
		#delimit    cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift]
		
		***Program cost
		nlcom 		1000*931986/((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*69.41), level(90)
		
		***Energy savings
		nlcom 		((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*69.41)/1000, level(90)		
		
	*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
***UNIT SALES, SUBSIDIZED (country-specific linear date trends)

reghdfe dlogunits i.presub3a##ib1.treata i.presub2a##ib1.treata i.presub1a##ib1.treata i.sub1a##ib1.treata i.sub2a##ib1.treata i.postsub1a##ib1.treata i.postsub2a##ib1.treata i.postsub3a##ib1.treata  mage mage2 , absorb(id2 cmt i.c#c.date) cluster(id) 
est store subu_trends

***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*(1+exp(_b[1.sub2a]))-2)) 
					(preshift: 	1/2*(exp(_b[1.presub1a])*(1+exp(_b[1.presub2a]))-2))
					(postshift:	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*exp(_b[1.sub2a])*exp(_b[1.postsub1a])*(1+exp(_b[1.postsub2a]))-2)), post;			
		#delimit    cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift]
		
		***Program cost
		nlcom 		1000*931986/((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*69.41), level(90)
		
		***Energy savings
		nlcom 		((_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift])*4239.035*14*69.41)/1000, level(90)			
		
	*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
***UNIT SALES, SUBSIDIZED (above, below median price)
reghdfe dlogunits i.presub3a##ib1.treata##ib1.medprice i.presub2a##ib1.treata##ib1.medprice i.presub1a##ib1.treata##ib1.medprice i.sub1a##ib1.treata##ib1.medprice i.sub2a##ib1.treata##ib1.medprice i.postsub1a##ib1.treata##ib1.medprice i.postsub2a##ib1.treata##ib1.medprice i.postsub3a##ib1.treata##ib1.medprice  mage mage2 , absorb(id2 cmt) cluster(id) 
est store subu_above

reghdfe dlogunits i.presub3a##ib1.treata##ib0.medprice i.presub2a##ib1.treata##ib0.medprice i.presub1a##ib1.treata##ib0.medprice i.sub1a##ib1.treata##ib0.medprice i.sub2a##ib1.treata##ib0.medprice i.postsub1a##ib1.treata##ib0.medprice i.postsub2a##ib1.treata##ib0.medprice i.postsub3a##ib1.treata##ib0.medprice  mage mage2 , absorb(id2 cmt) cluster(id) 
est store subu_below

esttab   subu subu_above subu_below, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a)
 
esttab   subu subu_above subu_below using "AT_10_wm_medianprice.tex", replace se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) 

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++				
***UNIT SALES, NON-SUBSIDIZED

reghdfe dlogunits i.presub3a##i.treata i.presub2a##i.treata i.presub1a##i.treata i.sub1a##i.treata i.sub2a##i.treata i.postsub1a##i.treata i.postsub2a##i.treata i.postsub3a##i.treata  mage mage2 , absorb(id2 cmt) cluster(id)
est store nonsubu

		***Program, preshift and postshift effects 
		#delimit;
		nlcom 		(program:  	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*(1+exp(_b[1.sub2a]))-2)) 
					(preshift: 	1/2*(exp(_b[1.presub1a])*(1+exp(_b[1.presub2a]))-2))
					(postshift:	1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*exp(_b[1.sub2a])*exp(_b[1.postsub1a])*(1+exp(_b[1.postsub2a]))-2)), post;			
		#delimit    cr
					
		***Net program effect 
		nlcom 		_b[program] + (2/2)*_b[preshift]+ (2/2)*_b[postshift]
		

 		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

***PRICES, SUBSIDIZED

reghdfe dlogprice i.presub3a##ib1.treata i.presub2a##ib1.treata i.presub1a##ib1.treata i.sub1a##ib1.treata i.sub2a##ib1.treata i.postsub1a##ib1.treata i.postsub2a##ib1.treata i.postsub3a##ib1.treata   mage mage2 if samples , absorb(id2 cmt) cluster(id)
est store subp

		nlcom 1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*(1+exp(_b[1.sub2a]))-2)
		
				
		
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***PRICES, NON-SUBSIDIZED	
	
reghdfe dlogprice i.presub3a##i.treata i.presub2a##i.treata i.presub1a##i.treata i.sub1a##i.treata i.sub2a##i.treata i.postsub1a##i.treata i.postsub2a##i.treata i.postsub3a##i.treata   mage mage2 if samples, absorb(id2 cmt) cluster(id)
est store nonsubp	
		
		nlcom 1/2*(exp(_b[1.presub2a])*exp(_b[1.presub1a])*exp(_b[1.sub1a])*(1+exp(_b[1.sub2a]))-2)
		
  
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
***TABLES

**UNITS AND PRICES
esttab   subu nonsubu subp nonsubp, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) 

esttab   subu nonsubu subp nonsubp  using "AT_10_wm.tex", replace se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a)

esttab   subu_cy  subu_trends, se star(* 0.10 ** 0.05 *** 0.01) mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a)
  
esttab   subu_cy  subu_trends using "AT_10_wm_cy.tex", replace se nostar mtitles nogaps b(%8.3f) t(%6.2f)  scalars(N ) order(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) keep(1.presub3a 1.presub2a 1.presub1a 1.sub1a 1.sub2a 1.postsub1a 1.postsub2a 1.postsub3a) 


restore


*log close
